package com.itrencai.d3_polymorphic.innerclass.anonymous;

public class Test2 {
    public static void main(String[] args) {
        Swimming s=new Swimming() {
            @Override
            public void swim() {
                System.out.println("学生快乐的自由泳~~~");
            }
        };
        go(s);
        System.out.println("--------------------");
        Swimming s1=new Swimming() {
            @Override
            public void swim() {
                System.out.println("老师游的很快~~~");
            }
        };
        go(s1);
        System.out.println("----------------");
        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("运动员才是真的快~~~");
            }
        });
    }

    //学生老师可以一起参加比赛
    public static void go(Swimming s){
        System.out.println("开始~~~");
        s.swim();
        System.out.println("结束~~~");
    }

    interface Swimming{
        void swim();
    }
}
